Skip to content

Conversation

@leonelsanchesdasilva
Copy link
Contributor

Com essa modificação será viável adicionar sugestões de melhorias do código para editores.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

📊 Cobertura de Código

Métrica Cobertura
Linhas 75.67%
Declarações 75.35%
Funções 70.56%
Branches 63.34%

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds column tracking (colunaInicio and colunaFim) to lexer tokens, enabling editors to provide more precise code suggestions and improvements. The changes update the Simbolo class and interface to include starting and ending column positions for each token.

Changes:

  • Added colunaInicio and colunaFim fields to SimboloInterface and Simbolo class
  • Updated all lexer implementations to calculate and store column positions when creating tokens
  • Modified semantic analyzer to propagate column information to code suggestions
  • Added comprehensive test coverage for column tracking functionality

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
fontes/interfaces/simbolo-interface.ts Added optional colunaInicio and colunaFim fields to the symbol interface
fontes/lexador/simbolo.ts Added colunaInicio and colunaFim properties and constructor parameters with default values
fontes/lexador/lexador.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/lexador-base.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/lexador-base-linha-unica.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/micro-lexador.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/micro-lexador-pitugues.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-tenda.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-prisma.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-portugol-ipt.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-pitugues.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-egua-classico.ts Updated adicionarSimbolo to calculate and include column positions
fontes/lexador/dialetos/lexador-calango.ts Updated adicionarSimbolo to calculate and include column positions
fontes/analisador-semantico/analisador-semantico.ts Updated to use symbol column information in code suggestions
fontes/analisador-semantico/analisador-semantico-base.ts Fixed import statement formatting
testes/lexador/lexador.test.ts Added comprehensive tests for column tracking across various token types
testes/analisador-semantico/analisador-semantico.test.ts Updated tests to verify column information in semantic suggestions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 111 to +116
adicionarSimbolo(tipo: string, literal: any = null): void {
const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo));
const comprimento = Math.max(texto.length, 1);
const colunaInicio = this.inicioSimbolo + 1;
const colunaFim = this.inicioSimbolo + comprimento;
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim));
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The identificarPalavraChave method directly creates a Simbolo instance without calling adicionarSimbolo. This method bypasses the column tracking logic added here, meaning keyword tokens won't have proper colunaInicio and colunaFim values. Consider refactoring this method to use adicionarSimbolo or to manually calculate and include column information when creating the Simbolo instance.

Copilot uses AI. Check for mistakes.
Comment on lines 86 to +91
adicionarSimbolo(tipo: any, literal?: any): void {
const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha, -1));
const comprimento = Math.max(texto.length, 1);
const colunaInicio = this.inicioSimbolo + 1;
const colunaFim = this.inicioSimbolo + comprimento;
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha, -1, colunaInicio, colunaFim));
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lexer has methods (analisarTexto, analisarNumero, identificarPalavraChave) that directly create Simbolo instances without calling adicionarSimbolo. These methods bypass the column tracking logic added here, meaning text, number, and keyword tokens won't have proper colunaInicio and colunaFim values. Consider refactoring those methods to use adicionarSimbolo or to manually calculate and include column information when creating Simbolo instances.

Copilot uses AI. Check for mistakes.
Comment on lines 89 to 98
adicionarSimbolo(tipo: any, literal?: any): void {
const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
const lexema = literal || texto;
const comprimentoLexema = typeof lexema === 'string' ? lexema.length : 0;
const comprimento = Math.max(comprimentoLexema, texto.length) || 1;
const colunaInicio = this.inicioSimbolo + 1;
const colunaFim = this.inicioSimbolo + comprimento;
this.simbolos.push(
new Simbolo(tipo, literal || texto, literal, this.linha + 1, this.hashArquivo)
new Simbolo(tipo, lexema, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim)
);
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lexer has methods (analisarTexto, analisarNumero, identificarPalavraChave) that directly create Simbolo instances without calling adicionarSimbolo. These methods bypass the column tracking logic added here, meaning text, number, and keyword tokens won't have proper colunaInicio and colunaFim values. Consider refactoring those methods to use adicionarSimbolo or to manually calculate and include column information when creating Simbolo instances.

Copilot uses AI. Check for mistakes.
Comment on lines +1123 to +1124
colunaInicio: declaracao.simbolo.colunaInicio,
colunaFim: declaracao.simbolo.colunaFim,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the Simbolo class always provides colunaInicio and colunaFim values (defaulting to 0), the SimboloInterface declares them as optional. This creates a type mismatch when assigning these potentially undefined values to CorrecaoSugeridaInterface, which requires non-optional number values. Consider using the nullish coalescing operator to provide a fallback value: colunaInicio: declaracao.simbolo.colunaInicio ?? 0 and colunaFim: declaracao.simbolo.colunaFim ?? 0.

Suggested change
colunaInicio: declaracao.simbolo.colunaInicio,
colunaFim: declaracao.simbolo.colunaFim,
colunaInicio: declaracao.simbolo.colunaInicio ?? 0,
colunaFim: declaracao.simbolo.colunaFim ?? 0,

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +10
colunaInicio: number;
colunaFim: number;
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency between the interface and implementation. The SimboloInterface defines colunaInicio and colunaFim as optional fields (with ?), but the Simbolo class implementation declares them as required (non-optional). While the constructor provides default values (0), this discrepancy could cause confusion. Consider making these fields optional in the class as well (colunaInicio?: number) to match the interface, or remove the optional marker from the interface if these fields should always be present.

Copilot uses AI. Check for mistakes.
Comment on lines 122 to 128
adicionarSimbolo(tipo: any, literal: any = null): void {
const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo));
const comprimento = Math.max(texto.length, 1);
const colunaInicio = this.inicioSimbolo + 1;
const colunaFim = this.inicioSimbolo + comprimento;
this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim));
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lexer has methods (analisarTexto, analisarNumero, identificarPalavraChave) that directly create Simbolo instances without calling adicionarSimbolo. These methods bypass the column tracking logic added here, meaning text, number, and keyword tokens won't have proper colunaInicio and colunaFim values. Consider refactoring those methods to use adicionarSimbolo or to manually calculate and include column information when creating Simbolo instances.

Copilot uses AI. Check for mistakes.
@leonelsanchesdasilva leonelsanchesdasilva merged commit ae0a022 into principal Feb 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant